local REL S_sourcing 
foreach R of local REL{
eststo clear   

capture drop relational
clonevar relational=`R'  
eststo: reghdfe ln_p_inpf_sbjo  relational  ln_q_sb_all sh_s_b sh_b_s age_buysel_month  ///
 ln_q_b_all age_buy_month  ln_q_inpf signatory ///
if sample==1 & s_in_labor_data==1, ///
abs(gr_sjt top_dest_b cohort_sb cohort_b) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,R,O}", replace  
  quietly estadd local est ="\scriptsize{Restricted}", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd local CTRL2 ="Yes", replace    
  quietly estadd scalar  U =  . , replace  
  
capture drop relational
clonevar relational=`R'  
eststo: reghdfe w_r  relational  ln_q_sb_all sh_s_b sh_b_s age_buysel_month  ///
 ln_q_b_all age_buy_month  ln_p_inpf_sbjo signatory ///
if sample==1 & s_in_labor_data==1, ///
abs(gr_sjt top_dest_b cohort_sb cohort_b) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,R,O}", replace  
  quietly estadd local est ="\scriptsize{Restricted}", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd local CTRL2 ="Yes", replace    
  quietly estadd scalar  U =  . , replace 

capture drop relational
clonevar relational=`R'  
eststo: reghdfe ln_numf_HS6_UD_imp  relational  ln_q_sb_all sh_s_b sh_b_s age_buysel_month  ///
 ln_q_b_all age_buy_month  ln_p_inpf_sbjo signatory ///
if sample==1 & s_in_labor_data==1, ///
abs(gr_sjt top_dest_b cohort_sb cohort_b) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,R,O}", replace  
  quietly estadd local est ="\scriptsize{Restricted}", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd local CTRL2 ="Yes", replace    
  quietly estadd scalar  U =  . , replace 
  
capture drop relational
clonevar relational=`R'   
eststo: reghdfe ln_p_sbjo  relational  ln_q_sb_all sh_s_b sh_b_s age_buysel_month  ///
 ln_q_b_all age_buy_month  ln_p_inpf_sbjo ln_q_sbjo signatory ///
if sample==1 & s_in_labor_data==1, ///
abs(gr_sjt top_dest_b cohort_sb cohort_b) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,R,O}", replace  
  quietly estadd local est ="\scriptsize{Restricted}", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd local CTRL2 ="Yes", replace    
  quietly estadd scalar  U =  . , replace   
  
capture drop relational
clonevar relational=`R'  
eststo: reghdfe ln_mu_sbjo  relational  ln_q_sb_all sh_s_b sh_b_s age_buysel_month  ///
 ln_q_b_all age_buy_month  ln_p_inpf_sbjo ln_q_sbjo signatory ///
if sample==1 & s_in_labor_data==1, ///
abs(gr_sjt top_dest_b cohort_sb cohort_b) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,R,O}", replace  
  quietly estadd local est ="\scriptsize{Restricted}", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd local CTRL2 ="Yes", replace    
  quietly estadd scalar  U =  . , replace     
 
}
esttab using "${tables}\TableD5PanelB.tex", ///
  label replace booktabs b(3) se(3) noconstant obslast substitute(\_ _) ///
  title("Buyers' Sourcing and Input Usage" \label{MaterialsUsage}) ///
  drop(ln_q_b_all ln_q_sb_all sh_s_b sh_b_s age_buysel_months  age_buy_months ln_p_inpf_sbjo ln_q_sbjo ln_q_inpf signatory _cons) order( ) /// 
  stats(FE CTRL est r2   N   , fmt( %~#s %~#s  %~#s 2 %12.0fc  )  ///
  labels("FEs" "Controls" "Sample" `"\(R^{2}\)"'  "Obs."  ))   ///
  star(* 0.10 ** 0.05 *** 0.01) ///
  nonotes  	

  
capture drop sample
gen sample=(n_ud==1 & S_pds==1)  
 
local REL S_sourcing 
foreach R of local REL{
eststo clear   

capture drop relational
clonevar relational=`R'  
eststo: reghdfe ln_p_inpf_sbjo  relational  ln_q_sb_all sh_s_b sh_b_s age_buysel_month  ///
 ln_q_b_all age_buy_month  ln_q_inpf signatory ///
if sample==1 & s_in_labor_data==1, ///
abs(gr_sjt top_dest_b cohort_sb cohort_b) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,R,O}", replace  
  quietly estadd local est ="\scriptsize{Restricted}", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd local CTRL2 ="Yes", replace    
  quietly estadd scalar  U =  . , replace  
  
capture drop relational
clonevar relational=`R'  
eststo: reghdfe w_r  relational  ln_q_sb_all sh_s_b sh_b_s age_buysel_month  ///
 ln_q_b_all age_buy_month  ln_p_inpf_sbjo signatory ///
if sample==1 & s_in_labor_data==1, ///
abs(gr_sjt top_dest_b cohort_sb cohort_b) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,R,O}", replace  
  quietly estadd local est ="\scriptsize{Restricted}", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd local CTRL2 ="Yes", replace    
  quietly estadd scalar  U =  . , replace 

capture drop relational
clonevar relational=`R'  
eststo: reghdfe ln_numf_HS6_UD_imp  relational  ln_q_sb_all sh_s_b sh_b_s age_buysel_month  ///
 ln_q_b_all age_buy_month  ln_p_inpf_sbjo signatory ///
if sample==1 & s_in_labor_data==1, ///
abs(gr_sjt top_dest_b cohort_sb cohort_b) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,R,O}", replace  
  quietly estadd local est ="\scriptsize{Restricted}", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd local CTRL2 ="Yes", replace    
  quietly estadd scalar  U =  . , replace 
  
capture drop relational
clonevar relational=`R'   
eststo: reghdfe ln_p_sbjo  relational  ln_q_sb_all sh_s_b sh_b_s age_buysel_month  ///
 ln_q_b_all age_buy_month  ln_p_inpf_sbjo ln_q_sbjo signatory ///
if sample==1 & s_in_labor_data==1, ///
abs(gr_sjt top_dest_b cohort_sb cohort_b) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,R,O}", replace  
  quietly estadd local est ="\scriptsize{Restricted}", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd local CTRL2 ="Yes", replace    
  quietly estadd scalar  U =  . , replace   
  
capture drop relational
clonevar relational=`R'  
eststo: reghdfe ln_mu_sbjo  relational  ln_q_sb_all sh_s_b sh_b_s age_buysel_month  ///
 ln_q_b_all age_buy_month  ln_p_inpf_sbjo ln_q_sbjo signatory ///
if sample==1 & s_in_labor_data==1, ///
abs(gr_sjt top_dest_b cohort_sb cohort_b) vce (cluster b_id)
  quietly estadd local CTRL ="\scriptsize{B,R,O}", replace  
  quietly estadd local est ="\scriptsize{Restricted}", replace  
  quietly estadd local FE ="sjt,d", replace  
  quietly estadd local CTRL2 ="Yes", replace    
  quietly estadd scalar  U =  . , replace     
 
}
esttab using "${tables}\TableD5PanelA.tex", ///
  label replace booktabs b(3) se(3) noconstant obslast substitute(\_ _) ///
  title("Buyers' Sourcing and Input Usage" \label{MaterialsUsage}) ///
  drop(ln_q_b_all ln_q_sb_all sh_s_b sh_b_s age_buysel_months  age_buy_months ln_p_inpf_sbjo ln_q_sbjo ln_q_inpf signatory _cons) order( ) /// 
  stats(FE CTRL est r2   N   , fmt( %~#s %~#s  %~#s 2 %12.0fc  )  ///
  labels("FEs" "Controls" "Sample" `"\(R^{2}\)"'  "Obs."  ))   ///
  star(* 0.10 ** 0.05 *** 0.01) ///
  nonotes  	
 
  